package com.ruoyi.project.service.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.domain.entity.ProjectSaleConfig;
import com.ruoyi.project.domain.entity.ProjectSaleLog;
import com.ruoyi.project.mapper.ProjectSaleConfigMapper;
import com.ruoyi.project.mapper.ProjectSaleLogMapper;
import com.ruoyi.project.service.IProjectFeeService;
import com.ruoyi.project.service.IProjectSaleConfigService;
import com.ruoyi.project.service.IProjectSaleLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 收款出库单关联Service业务层处理
 * 
 * @author zzy
 * @date 2025-11-27
 */
@Service
public class ProjectSaleConfigServiceImpl  extends ServiceImpl<ProjectSaleConfigMapper, ProjectSaleConfig> implements IProjectSaleConfigService
{
    @Autowired
    private ProjectSaleConfigMapper projectSaleConfigMapper;

    @Autowired
    private IProjectFeeService projectFeeService;

    /**
     * 查询收款出库单关联
     * 
     * @param id 收款出库单关联主键
     * @return 收款出库单关联
     */
    @Override
    public ProjectSaleConfig selectProjectSaleConfigById(Long id)
    {
        return projectSaleConfigMapper.selectById(id);
    }

    /**
     * 查询收款出库单关联列表
     * 
     * @param projectSaleConfig 收款出库单关联
     * @return 收款出库单关联
     */
    @Override
    public List<ProjectSaleConfig> selectProjectSaleConfigList(ProjectSaleConfig projectSaleConfig)
    {
        LambdaQueryWrapper<ProjectSaleConfig> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ProjectSaleConfig::getFeeKey, projectSaleConfig.getFeeKey());
        return projectSaleConfigMapper.selectList(queryWrapper);
    }

    /**
     * 新增收款出库单关联
     * 
     * @param projectSaleConfig 收款出库单关联
     * @return 结果
     */
    @Override
    public int insertProjectSaleConfig(ProjectSaleConfig projectSaleConfig)
    {
        projectSaleConfig.setCreateTime(DateUtils.getNowDate());
        return projectSaleConfigMapper.insert(projectSaleConfig);
    }

    /**
     * 修改收款出库单关联
     * 
     * @param projectSaleConfig 收款出库单关联
     * @return 结果
     */
    @Override
    public int updateProjectSaleConfig(ProjectSaleConfig projectSaleConfig)
    {
        projectSaleConfig.setUpdateTime(DateUtils.getNowDate());
        return projectSaleConfigMapper.updateById(projectSaleConfig);
    }

    @Override
    public void saveOrUpdateProjectSaleConfig(ProjectSaleConfig projectSaleConfig) {

    }

    /**
     * 批量删除收款出库单关联
     * 
     * @param ids 需要删除的收款出库单关联主键
     * @return 结果
     */
    @Override
    public int deleteProjectSaleConfigByIds(Long[] ids)
    {
        List<Long> idsList = Arrays.asList(ids);
        return projectSaleConfigMapper.deleteBatchIds(idsList);
    }

    /**
     * 删除收款出库单关联信息
     * 
     * @param id 收款出库单关联主键
     * @return 结果
     */
    @Override
    public int deleteProjectSaleConfigById(Long id)
    {
        return projectSaleConfigMapper.deleteById(id);
    }
}
